# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Lars Kanis <lars@greiz-reinsdorf.de>

_realname=freetds
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.5.1
pkgrel=1
pkgdesc="A free implementation of Sybase's DB-Library, CT-Library and ODBC libraries (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.freetds.org/'
msys2_repository_url='https://github.com/FreeTDS/freetds/'
msys2_changelog_url='https://www.freetds.org/news.html'
msys2_documentation_url='https://www.freetds.org/docs.html'
msys2_issue_tracker_url='https://github.com/FreeTDS/freetds/issues/'
msys2_references=(
  'archlinux: freetds'
  "cpe: cpe:/a:freetds:freetds"
)
license=('spdx:LGPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-openssl"
         "${MINGW_PACKAGE_PREFIX}-libiconv")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-pkgconf")
source=(https://www.freetds.org/files/stable/freetds-${pkgver}.tar.gz)
sha256sums=('c9f530b0678f6d1f036efae66b1bfdff2738ca2cb41b51d11f80f31451ac2675')

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../freetds-${pkgver}/configure \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --includedir=${MINGW_PREFIX}/include/${_realname} \
    --enable-static \
    --enable-shared \
    --with-openssl \
    --enable-sspi

  make
}

package () {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
